<template>
    <div>
        <div class="banner" @click="handleBannerClick">
            <img class="banner-img" :src="bannerImg" alt="">
            <div class="banner-info">
                <div class="banner-title">
                    {{this.sightName}}
                </div>
                <div class="banner-number">
                    <span class="iconfont banner-icon">&#xe6ee;</span>
                    {{this.bannerImgs.length}}
                </div>
            </div>
        </div>
        <!-- 使用了v-show导致swiper样式发生了变化 -->
        <common-gallary :imgs='bannerImgs' v-show='showGallary' @close='handleGallaryClose'></common-gallary>
    </div>
</template>

<script>
import CommonGallary from 'common/gallary/Gallary'
export default {
    name: 'DetailBanner',
    props: {
        sightName: String,
        bannerImg: String,
        bannerImgs: Array
    },
    data() {
        return {
            showGallary: false
        }
    },
    methods: {
        // 当点击页面时，进入画廊页面
        handleBannerClick(){
            this.showGallary = true
        },
        // 当点击画廊页面时，进入主页面
        handleGallaryClose(){
            this.showGallary = false
        }
    },
    components: {
        CommonGallary
    }
}
</script>

<style lang="stylus" scoped>
    // 防止页面抖动
    .banner
        position relative
        overflow hidden
        height 0
        padding-bottom 55%
        .banner-img
            width 100%
        .banner-info
            display flex
            position absolute
            left 0
            right 0
            bottom 0
            line-height .6rem
            color #fff
            .banner-title
                flex 1
                font-size .26rem
                padding 0 .2rem
            .banner-number
                margin-top .14rem
                margin-right .2rem
                padding 0 .4rem
                height .32rem
                line-height .32rem
                border-radius .2rem
                background rgba(255, 0, 0, 1)
                font-size .24rem
                .banner-icon
                    font-size .24rem
</style>